<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 复制
        // const obj = {
        //     id: 1,
        //     age: 12,
        //     name: 'lisi'
        // }
        // const obj2 = {...obj};
        // obj.age = 20;
        // console.log(obj2);
        
        // const arr1 = [1, 2, 3, 4];
        // const arr2 = [...arr1];
        // arr1.push(10);
        // console.log(arr2);
        

        // 合并
        const arr1 = [1, 2, 3,];
        const arr2 = [4, 5, 6];
        const arr = [...arr1, ...arr2];
        console.log(arr);
        
        const obj1 = {
            name: 'lisi',
            age: 12,
        }
        const obj2 = {
            age: 20,
            price: 40
        }
        const obj = {...obj1, ...obj2}; // age 后来的会将前面的覆盖
        console.log(obj);
        
    </script>
</body>
</html>